package com.suny.guarded_suspension.BlockingQueue;

import com.suny.guarded_suspension.Request;

import java.util.concurrent.LinkedBlockingQueue;

public class RequestQueue {
    private final LinkedBlockingQueue<Request> queue = new LinkedBlockingQueue<>();

    /**
     * 获取request
     * @return
     */
    public Request getRequest() {
        Request request = null;
        try {
            request = queue.take();
        } catch (InterruptedException e) {
        }
        return request;
    }

    /**
     * 添加request
     * @param request
     */
    public void putRequest(Request request) {
        try {
            queue.put(request);
        } catch (InterruptedException e) {
        }
    }
}
